home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / GameKit / Examples / PacMan / Monster.h < prev    next >
Text File  |  1995-06-12  |  2KB  |  68 lines

  1.  
  2. // This object moves and renders the Ghosts that chase and kill you.
  3.  
  4. #import <gamekit/gamekit.h>
  5.  
  6. typedef int intm[8];    // used in the arrays to control movement of ghosts
  7.  
  8. // valid states for a ghost
  9. #define HOVER    0
  10. #define CHASE    1
  11. #define RUN        2
  12. #define HOME    3
  13.  
  14. #define HARMLESS 2    // return value for munch (YES/NO/HARMLESS)
  15.  
  16. // ghost colors (for "myColor" instance variable)
  17. #define BLUE_GHOST        0
  18. #define GREEN_GHOST        1
  19. #define ORANGE_GHOST    2
  20. #define PURPLE_GHOST    3
  21. #define INVISIBLE_GHOST    4
  22. #define GHOST_EYES        5
  23.  
  24. // power dot states
  25. #define DOT_NONE    0
  26. #define DOT_EATEN    1
  27. #define DOT_FADING    2
  28.  
  29. @interface Monster:GameActor
  30. {
  31.     id    player;        // This is who we chase
  32.     id    maze;        // This is where we are
  33.     id  ghosts[3];        // The tiff of the ghost images
  34.     
  35.     BOOL eatable;    // Can we be eaten ??
  36.     int lastSense;    // Previous value of "sense"
  37.     int powerState;    // what's the power dot state
  38.     int powerTime;    // how long power dot's been on
  39.     int state;        // what we're doing
  40.     int fix;        // fix flag for hovering movement
  41.     int loops;        // number of times we've circled around in the ghost box
  42.     
  43.     int img;        // which animation frame to use
  44.     int myColor;    // which ghost (0-3) am I?
  45.     
  46. }
  47.  
  48. - init;    // Calls method below with semi-sane values...but you should use below:
  49. - initGhost:(int)num player:(id)pac maze:(id)world at:(int)sx :(int)sy;
  50.     // designated initializer; initializes all the ghosts.
  51. - renderAt:(int)posx :(int)posy move:(BOOL)moveOk;    // draw ghost...
  52.     // lockfocus in the view where it's drawn first.
  53. - move:sender;            // decide where to move the ghost for the next frame
  54. - powerDot:(BOOL)eat;    // called when power dots are eaten or run out.
  55. - (BOOL)canBeEaten;        // returns "eatable".
  56. - (int)munch;            // called when pac intersects ghost
  57.  
  58. // These four methods handle actual movement.  They are internal, and generally
  59. // called by the (-move:) method.  You shouldn't ever use them directly!
  60. - hover;            // hover moves solid ghost when in ghost chamber
  61. - runAway;            // ghost runs away at 1/2 speed after power pill
  62. - chase;            // ghost chases player down
  63. - goHome;            // used to make the eyes run to ghost chamber at 2x speed
  64. - moveOneFrame;        // makes the animation advance one step.
  65. - powerCount;        // power dot count down
  66.  
  67. @end
  68.